package com.cloud.mall.consume.config;

import com.alibaba.fastjson.JSONObject;
import com.cloud.mall.consume.domain.ErrorLog;
import com.cloud.mall.consume.service.ErrorService;
import com.cloud.mall.consume.wechat.common.MessageTemplate;
import com.cloud.mall.consume.wechat.common.Result;
import com.cloud.mall.consume.wechat.config.WechatConf;
import com.cloud.mall.core.bean.MallBeanUtils;
import com.cloud.mall.log.mapper.MallErrorLogMapper;
import com.cloud.mall.log.mapper.SenderContactsMapper;
import com.cloud.mall.log.model.MallErrorLog;
import com.cloud.mall.log.model.MallErrorLogExample;
import com.cloud.mall.log.model.SenderContacts;
import com.cloud.mall.log.model.SenderContactsExample;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Component
@RabbitListener(queues = "mall-log-error")
@Slf4j
public class DirectReceiver {

    @Autowired
    private ErrorLogFactory errorLogFactory;

    @RabbitHandler
    public void process(String jsonStr) {
        ErrorLog errorLog = JSONObject.parseObject(jsonStr, ErrorLog.class);
        ErrorService errorService=errorLogFactory.getErrorService(errorLog.getError());
        errorService.sendMessage(errorLog);
    }


}
